package com.example.Exception;

import java.util.Scanner;

public class ExceptionDemo {
    public static void main(String[] args) {

        try {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入你的年龄");
            String line = sc.nextLine();
            int age = Integer.parseInt(line); //格式化异常
            System.out.println(age);
            System.out.println(2 / 0);  //数学异常
        } catch (NumberFormatException e) {
            System.out.println("看看执行了吗？");
        } catch (ArithmeticException e) {
            System.out.println("数学运算异常出现了");
        }
        //以后我们针对于每种不同的异常,有可能会有不同的处理结果
        System.out.println("测试456");

    }
}
